package daily.oct;

/*这题已经在100热题中做过，这次是在每日打卡中重做一遍 */

public class lc11v2 {
    public int maxArea(int[] height) {
        int left = 0, right = height.length - 1;
        int maxArea = 0;
        while (left < right) {
            int Height = Math.min(height[left], height[right]);
            int width = right - left;
            int area = Height * width;
            maxArea = Math.max(maxArea, area);

            if (height[left] < height[right]) {
                left++;
            } else {
                right--;
            }

        }

        return maxArea;
    }
    
    public static void main(String[] args) {
        int[] height1={1,8,6,2,5,4,8,3,7};
        int[] height2={1,1};
        lc11v2 lc11=new lc11v2();
        System.out.println(lc11.maxArea(height1));
        System.out.println(lc11.maxArea(height2));
    }
    
}
